<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib tagdir="/WEB-INF/tags/sys"  prefix="sys"%>
<%@ taglib uri="/WEB-INF/tlds/webui.tld"  prefix="webui"%>

<webui:enum var="operateTypeEnum" code="OperateType" />
<webui:enum var="objectTypeEnum" code="ObjectType" />
<webui:enum var="orgEnum" code="OrgEnum" appendJs="true"/>
<webui:enum var="operatorEnum" code="operatorEnum" />
<script>
	function editRecord(table,data){
		var logs = data.data;
		$(logs).each(function(index,element){
			var _self = this;
			var editContent = element.oplog.formParameters;
			var orgName = orgEnum[element.cpContent.orgId];
			if(editContent.length>100){
				editContent = editContent.substring(0,100)+"...";
			}
			Vue.set(_self,"editContent",editContent);
			Vue.set(_self,"orgName",orgName);
		});
		var contentCount = data.page.totalElements;
		if(!document.getElementById("table_length")){
			$("#tb_logs_paginate").parent().prev().append("<div id='table_length' style='float:left'></div>");
		}
		if (contentCount > 0) {
			$("#table_length").html("共"+contentCount+"条数据");
		} else {
			$("#table_length").html("");
		}
	}
	function EditContents(id){
		$("#myModal").modal();
		$.ajax({
			type:"get",
			url:"${contextPath}/rest/oplogs/"+id,
			success:function(datas){
				$("#bodyContent").html(datas.formParameters);
			}
		});
	}
</script>
<%-- 弹出框 --%>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
					&times;
				</button>
				<h4 class="modal-title" id="myModalLabel">
					修改内容
				</h4>
			</div>
			<div id="bodyContent" class="modal-body">
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-default" data-dismiss="modal">关闭
				</button>
			</div>
		</div>
	</div>
</div>
<webui:panel title="修改记录">
	<webui:form id="historySearchForm" styleClass="form-horizontal" action="${contextPath}/declare/cpContent/cpContentAndOplog.action?operateType=edit"
				method="get" name="historySearchForm">
		<webui:input label="片名" name="name" styleClass="col-sm-4" labelClass="col-sm-4" inputClass="col-sm-8"
					type="text"></webui:input>
		<webui:select label="CP名称" name="orgName" styleClass="col-sm-4" labelClass="col-sm-4" inputClass="col-sm-8"
					lookup="${orgEnum}"></webui:select>
		<webui:select label="操作员" name="opName" styleClass="col-sm-4" labelClass="col-sm-4" inputClass="col-sm-8"
					lookup="${operatorEnum}"></webui:select>
		<div class="col-sm-12"></div>
		<webui:datepicker beginId="beginTimeSearch" beginName="beginTime" label="修改时间" styleClass="col-sm-5" labelClass="col-sm-3" inputClass="col-sm-9"
							 endName="endTime" endId="endTimeSearch" level="date" duration="true">
		</webui:datepicker>
		<webui:button type="button" styleClass="col-sm-6" inputClass="col-sm-1" buttonClass="btn-primary" label="" labelClass="col-sm-4"
						onclick="tb_logs.filter()">查询
		</webui:button>
	</webui:form>
	<webui:table id="tb_logs" datas="data" dataUrl="${contextPath}/declare/cpContent/cpContentAndOplog.action?operateType=edit"
				 dataload="editRecord" searchForm="#historySearch">
		<webui:column field="name" title="片名">{{row.cpContent.name}}</webui:column>
		<webui:column field="orgName" title="CP名称">{{row.orgName}}</webui:column>
		<webui:column field="operateTime" title="修改时间" style="width:130px;">{{row.oplog.operateTime| moment('YYYY-MM-DD HH:mm:ss')}}</webui:column>
		<webui:column field="opName" title="操作员">{{row.oplog.opName}}</webui:column>
		<webui:column field="formParameters" title="修改内容" style="width:640px;">
			<a v-bind:href="'javascript:EditContents('+row.oplog.id+')'">{{row.editContent}}</a>
		</webui:column>
	</webui:table>
</webui:panel>